#ifndef __WIZ_BASE_UTILS_PTRGUARD_HPP__SHANHAOBO__19800429__
#define __WIZ_BASE_UTILS_PTRGUARD_HPP__SHANHAOBO__19800429__

#include "./WizBaseUtilsPtr.hpp"

namespace Wiz
{
    namespace PtrGuard
    {
        template<class GuardedT>
        class Type : public ::Wiz::Ptr::Type<GuardedT>
        {
            typedef GuardedT                    tGuarded;

            typedef Type<tGuarded>              tThis;
            typedef ::Wiz::Ptr::Type<tGuarded>  tSuper;

            typedef tGuarded &                  tGuardedRef;
            typedef tGuarded const &            tGuardedRefConst;
            typedef tGuarded *                  tGuardedPtr;
            typedef tGuarded const *            tGuardConstPtr;
            typedef tGuarded * const            tGuardFixedPtr;

        public:
            Type() : tSuper(new tGuarded)
            {
            }

            Type(tGuardedPtr InPtr) : tSuper(InPtr)
            {
            }

            ~Type()
            {
                if (m_RawPtr != WIZ_NULLPTR)
                {
                    ::Wiz::Delete(m_RawPtr);
                    m_RawPtr = WIZ_NULLPTR;
                }
            }

        public:
            tGuardedPtr Acquire()
            {
                tGuardFixedPtr TempPtr = m_RawPtr;

                m_RawPtr = WIZ_NULLPTR;

                return TempPtr;
            }
        }; /// end of class Type
    } /// end of namespace PtrGuard
} /// end of namespace Wiz

#endif /*__WIZ_BASE_UTILS_PTRGUARD_HPP__SHANHAOBO__19800429__*/
